package com.yiwyn.springmixedsql.config;


import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import java.util.Map;

@Slf4j
@Configuration
public class DbConfig {

    @Autowired
    private ApplicationContext applicationContext;

    @PostConstruct
    public void getALlSqlSessionFactories() {
        Map<String, SqlSessionFactory> beansOfType = applicationContext.getBeansOfType(SqlSessionFactory.class);
        for (Map.Entry<String, SqlSessionFactory> stringSqlSessionFactoryEntry : beansOfType.entrySet()) {
            log.info("beanName:{} bean:{}", stringSqlSessionFactoryEntry.getKey(), stringSqlSessionFactoryEntry.getValue());
        }
    }


}
